import request from '@/utils/request'
import da from "element-ui/src/locale/lang/da";

//商家登录
export function login(data) {
  return request({
    url: '/merchantLogin',
    method: 'post',
    params: {
      mName: data.mName,
      mPassword: data.mPassword,
    }
  })
}

//商家注册
export function merchantRegister(data) {
  return request({
    url: '/merchantRegister',
    method: 'post',
    data
  })
}

//商家查看全部商品
export function findAllGoods(data) {
  return request({
    url: '/selectAllGoods',
    method: 'post',
    params: {
      mId: data.mId,
    }

  })
}

//商家查看全部订单
export function getOrdersAllMerchant(data) {
  return request({
    url: '/getOrdersAllMerchant',
    method: 'post',
    params: {
      mid: data.mid,
    }
  })
}

//商家的商品新增
export function add(data) {
  return request({
    url: '/addGoods',
    method: 'post',
    data: data,
    header: {'Content-Type': 'multipart/form-data'},
  })
}


//商家的商品修改+图片
export function update(data) {
  return request({
    url: '/updateImgGoods',
    method: 'post',
    data:data,
    header: {'Content-Type':'multtpart/form-data'},
  })
}
//商家的商品修改
export function updateNo(data) {
  return request({
    url: '/updateGoods',
    method: 'post',
    data: data,
    header: {'Content-Type': 'multtpart/form-data'},
  })
}

//商家的商品通过mId查询
export function selectBymId(data) {
  return request({
    url: '/selectAllGoods',
    method: 'post',
    params: {
      mId: data.mId,
      gName: data.gName,
    }
  })
}

//商家的商品分页查询
export function findPageBymId(data) {
  return request({
    url: '/selectPageGoods',
    method: 'post',
    params: {
      pageNum: parseInt(data.pageNum),
      pageSize: 5,
      mId: data.mId,
      gName: data.gName
    }
  })
}

//商家的商品搜索框
export function findGoods(data) {
  return request({
    url: '/selectLikeName',
    method: 'post',
    params: {
      mId: data.mId,
      gName: data.gName,
    }
  })
}

//商家的商品删除
export function deleteGood(data) {
  return request({
    url: '/deleteGoods',
    method: 'post',
    params: {
      gId: parseInt(data.gId),
    }
  })
}

//商家的商品状态更换
export function updateGoodsState(data) {
  return request({
    url: '/updateGoodsState',
    method: 'post',
    params: {
      gId: parseInt(data.gId),
      gState: data.gState,
    }
  })
}

//商家的商品详情
export function selectBygId(data) {
  return request({
    url: '/selectBygId',
    method: 'post',
    params: {
      gId: parseInt(data.gId),
    }
  })
}

//商家的订单列表查询
export function findOrdersAllMerchant2(data) {
  return request({
    url: '/findOrdersAllMerchant2',
    method: 'post',
    params:{
      mid:data.mid,
    }
  })
}

//商家修改用户订单信息
export function modifyOrderMerchant2(data) {
  return request({
    url:'/modifyOrderMerchant2',
    method:'post',
    params:{
      uid: data.uid,
      gid: data.gid,
      mid: data.mid,
      oName: data.oName,
      oPhone: data.oPhone,
      oAddress: data.oAddress,
      cNumber: data.cNumber,
    }
  })
}

//商家选择发货
export function changeOrderState2(data) {
  return request({
    url:'/changeOrderState2',
    method:'post',
    params:{
      oState: '已发货',
      uid: data.uid,
      gid: data.gid,
      mid: data.mid,
      cNumber: data.cNumber,
    }
  })
}
